home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
PowerMacOberon 1.2
/
Dialogs
/
DialogInsert.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1995-06-30
|
7KB
|
154 lines
Syntax10.Scn.Fnt
Syntax10i.Scn.Fnt
StampElems
Alloc
8 May 95
Syntax10b.Scn.Fnt
MODULE DialogInsert;
(* Markus Knasm
ller 3 Aug 94 -
IMPORT DialogFrames, DialogListBoxes, Dialogs, DialogTexts, Oberon, TextFrames, Texts, Viewers;
VAR wr: Texts.Writer;
PROCEDURE Open*;
VAR x, y: INTEGER; panel: Dialogs.Panel; w: Texts.Writer; t: Texts.Text; o: Dialogs.Object;
BEGIN
panel := Dialogs.cmdPanel;
o := panel.NamedObject ("l");
WITH o: DialogListBoxes.Item DO
Texts.OpenWriter (w);
Texts.WriteString (w, "CheckBox"); Texts.WriteLn (w);
Texts.WriteString (w, "Button"); Texts.WriteLn (w);
Texts.WriteString (w, "StaticText"); Texts.WriteLn (w);
Texts.WriteString (w, "RadioButton"); Texts.WriteLn (w);
Texts.WriteString (w, "GroupBox"); Texts.WriteLn (w);
Texts.WriteString (w, "Text"); Texts.WriteLn (w);
Texts.WriteString (w, "Line"); Texts.WriteLn (w);
Texts.WriteString (w, "Circle"); Texts.WriteLn (w);
Texts.WriteString (w, "Rectangle"); Texts.WriteLn (w);
Texts.WriteString (w, "Slider"); Texts.WriteLn (w);
Texts.WriteString (w, "IntegerSlider"); Texts.WriteLn (w);
Texts.WriteString (w, "Clock"); Texts.WriteLn (w);
Texts.WriteString (w, "AnalogClock"); Texts.WriteLn (w);
Texts.WriteString (w, "Date"); Texts.WriteLn (w);
Texts.WriteString (w, "ColorPicker"); Texts.WriteLn (w);
Texts.WriteString (w, "ListBox"); Texts.WriteLn (w);
Texts.WriteString (w, "ComboBox"); Texts.WriteLn (w);
Texts.WriteString (w, "Graphic"); Texts.WriteLn (w);
Texts.WriteString (w, "KeplerGraph");
t := TextFrames.Text (""); Texts.Append (t, w.buf);
o.SetMenu (t)
ELSE HALT (99)
END
END Open;
PROCEDURE ReadInt (o: Dialogs.Object; VAR res: INTEGER);
(* reads an integer from a dialogtext element *)
VAR t: Texts.Text; s: Texts.Scanner;
BEGIN
WITH o: DialogTexts.Item DO
t := o.GetText (); Texts.OpenScanner (s, t, 0); Texts.Scan (s); res := Dialogs.ok;
IF s.class = Texts.Int THEN Texts.WriteInt (wr, s.i, 0); Texts.Append (Oberon.Par.text, wr.buf)
ELSE res := Dialogs.wrongInput END
ELSE
res := Dialogs.wrongInput
END;
END ReadInt;
PROCEDURE ReadName (o: Dialogs.Object);
VAR t: Texts.Text; r: Texts.Reader; string: ARRAY 32 OF CHAR; i: INTEGER; ch: CHAR;
BEGIN
WITH o: DialogTexts.Item DO
t := o.GetText (); Texts.OpenReader (r, t, 0); Texts.Read (r, ch); i := 0;
WHILE ~r.eot DO
string[i] := ch; INC (i); Texts.Read (r, ch)
END;
string[i] := 0X
ELSE
END;
Texts.WriteString (wr, string); Texts.Delete (Oberon.Par.text, 0, Oberon.Par.text.len);
Texts.Append (Oberon.Par.text, wr.buf)
END ReadName;
PROCEDURE ReadCmd (o: Dialogs.Object; VAR string: ARRAY OF CHAR);
VAR t: Texts.Text; s: Texts.Scanner;
BEGIN
WITH o: DialogTexts.Item DO
t := o.GetText (); Texts.OpenScanner (s, t, 0); Texts.Scan (s);
IF s.class = Texts.Name THEN COPY (s.s, string) ELSE COPY ("", string) END
ELSE
END
END ReadCmd;
PROCEDURE ReadPar (o: Dialogs.Object; VAR string: ARRAY OF CHAR);
VAR t: Texts.Text; r: Texts.Reader; ch: CHAR; i: INTEGER;
BEGIN
WITH o: DialogTexts.Item DO
t := o.GetText (); Texts.OpenReader (r, t, 0); Texts.Read (r, ch); i := 0;
WHILE ~r.eot DO
string[i] := ch; INC (i); Texts.Read (r, ch)
END;
string[i] := 0X
ELSE
END
END ReadPar;
PROCEDURE ReadXYWH;
(* reads the lower left corner coordinates, wide and height from the Demo-Panel *)
VAR ox, oy, ow, oh: Dialogs.Object; i, res, x, y: INTEGER; panel, p: Dialogs.Panel;
BEGIN
panel := Dialogs.cmdPanel;
ox := panel.NamedObject ("x"); oy := panel.NamedObject ("y");
ow := panel.NamedObject ("w"); oh := panel.NamedObject ("h");
DialogFrames.GetCaretPosition (p, x, y);
ReadInt (ox, res); IF res # 0 THEN Texts.WriteInt (wr, x, 0); Texts.Append (Oberon.Par.text, wr.buf) END;
Texts.WriteString (wr, " "); Texts.Append (Oberon.Par.text, wr.buf);
ReadInt (oy, res); IF res # 0 THEN Texts.WriteInt (wr, y, 0); Texts.Append (Oberon.Par.text, wr.buf) END;
Texts.WriteString (wr, " "); Texts.Append (Oberon.Par.text, wr.buf);
ReadInt (ow, res); IF res # 0THEN Texts.WriteInt (wr, -1, 0); Texts.Append (Oberon.Par.text, wr.buf) END;
Texts.WriteString (wr, " "); Texts.Append (Oberon.Par.text, wr.buf);
ReadInt (oh, res); IF res # 0THEN Texts.WriteInt (wr, -1, 0); Texts.Append (Oberon.Par.text, wr.buf) END;
END ReadXYWH;
PROCEDURE ReadNameCmdPar (VAR cmd, par: ARRAY OF CHAR);
VAR on, op, oc: Dialogs.Object;
BEGIN
on := Dialogs.cmdPanel.NamedObject ("name"); oc := Dialogs.cmdPanel.NamedObject ("cmd");
op := Dialogs.cmdPanel.NamedObject ("par");
ReadName (on); ReadCmd (oc, cmd); ReadPar (op, par)
END ReadNameCmdPar;
PROCEDURE Do*;
VAR
o, last: Dialogs.Object; p: Dialogs.Panel; name: Texts.Buffer; cmd, par, insert: ARRAY 64 OF CHAR;
t: Texts.Text; x, y, w, h, res: INTEGER; r: Texts.Reader; ch: CHAR; v: Viewers.Viewer;
BEGIN
last:= Dialogs.lastin; v := Oberon.Par.vwr;
Oberon.Par.text := TextFrames.Text (""); Texts.OpenWriter (wr);
ReadNameCmdPar (cmd, par); Texts.WriteString (wr, " "); Texts.Append (Oberon.Par.text, wr.buf);
ReadXYWH;
o := Dialogs.cmdPanel.NamedObject ("l");
WITH o: DialogListBoxes.Item DO
IF o.selline = 0 THEN insert := "DialogCheckBoxes.Insert"
ELSIF o.selline = 1 THEN insert := "DialogButtons.Insert"
ELSIF o.selline = 2 THEN insert := "DialogStaticTexts.Insert"
ELSIF o.selline = 3 THEN insert := "DialogRadioButtons.Insert"
ELSIF o.selline = 4 THEN insert := "DialogGroupBoxes.Insert"
ELSIF o.selline = 5 THEN insert := "DialogTexts.Insert"
ELSIF o.selline = 6 THEN insert := "DialogLines.Insert"
ELSIF o.selline = 7 THEN insert := "DialogCircles.Insert"
ELSIF o.selline = 8 THEN insert := "DialogRectangles.Insert"
ELSIF o.selline = 9 THEN insert := "DialogSliders.Insert"
ELSIF o.selline = 10 THEN insert := "DialogIntSliders.Insert"
ELSIF o.selline = 11 THEN insert := "DialogClocks.Insert"
ELSIF o.selline = 12 THEN insert := "DialogAnalogClocks.Insert"
ELSIF o.selline = 13 THEN insert := "DialogDates.Insert"
ELSIF o.selline = 14 THEN insert := "DialogColorPickers.Insert"
ELSIF o.selline = 15 THEN insert := "DialogListBoxes.Insert"
ELSIF o.selline = 16 THEN insert := "DialogComboBoxes.Insert"
ELSIF o.selline = 17 THEN insert := "DialogGraphics.Insert"
ELSIF o.selline = 18 THEN insert := "DialogKeplers.Insert"
END
ELSE
END;
Oberon.Call (insert, Oberon.Par, FALSE, res);
IF (Dialogs.lastin # last) & (par[0] # 0X) THEN Dialogs.lastin.SetPar (par) END;
IF (Dialogs.lastin # last) & (cmd[0] # 0X) THEN Dialogs.lastin.SetCmd (cmd) END;
t := v.dsc (TextFrames.Frame).text;
Texts.OpenReader (r, t, t.len - 1); Texts.Read (r, ch);
IF ch = "!" THEN Texts.Delete (t, t.len - 1, t.len) END
END Do;
END DialogInsert.